import request from '@/utils/request'
import type { Topic, TopicListRequest, TopicResponse } from './pass-groupModel';

export function getTopicList(params: TopicListRequest): Promise<TopicResponse> {
  return request({
    url: `/online/pass-generate/pass-group`,
    params
  })
}

export function newTopic(data: {passName: string, remark: string}):Promise<void> {
  return request({    
    url: '/online/pass-generate/pass-group',
    data,
    method: 'POST'
  })
}

export function deleteTopic(topicId: number):Promise<boolean> {
  return request({
    url: '/online/pass-generate/pass-group',
    params: {topicId},
    method: 'DELETE'
  })
}

export function getTopicTemplates(topicId: string):Promise<Topic> {
  return request({
    url: '/online/pass-generate/pass-group/pass',
    params: {
      topicId
    }
  })
}

export function getAllTopicsAndTemplates(params: TopicListRequest):Promise<Topic[]> {
  return request({
    url: '/online/pass-generate/pass-group/list',
    params
  })
}

export function setMerchantTopic(payload :{topicId:number , mrchId: number[]}) {
  return request({
    url: '/online/pass-generate/pass-group/issuer',
    method: 'POST',
    params: {
      topicId: payload.topicId
    },
    data: {
      mrchId: payload.mrchId
    }
  })
}

export function renameTheme(payload :{themeId:string , themeName: string}) {
  return request({
    url: '/online/pass-generate/pass-group',
    method: 'PUT',
    params: payload
  })
}

